<template>
  <div class="es-sdk-root-css" >
    <customer-notice ref="customerNoticeRef" @onAgreeClick="onAgreeClick"/>
  </div>
</template>

<script lang="ts">
import {defineComponent} from "@vue/runtime-core";
import {useESRouter} from "@extscreen/es3-router";
import {useESDevelop, useESToast, useESLog, useES, useESDownload} from "@extscreen/es3-core";
import CustomerNotice from '../../views/CustomerNotice';
import {ref} from "vue";
import {getAgreementKey} from "../config/global";

const TAG = "TESLog"

export default defineComponent({
  name: "es-splash-page",
  components: {
    CustomerNotice
  },
  setup() {
    const log = useESLog();
    const develop = useESDevelop();
    const router = useESRouter();
    const toast = useESToast();
    const es = useES()
    const download = useESDownload()
    const customerNoticeRef=ref()

    const path = es.getESAppFilePath()
    const onESCreate = (params) => {
      // let aa: string = '22222'
      // log.e(TAG, "--------onESCreate-----develop->>>>>", develop.getPackageName())
      // log.e(TAG, "--------onESCreate---Hello ESPlayerLog-#######->>>>>", aa, log)
      console.log('----页面路由---SPLASH----onESCreate---44444-------', params)

      // toast.showToast("Splash onESCreate")
      const key = getAgreementKey();
      localStorage.getItem(key)
        .then(res=>{
          if (res !== '1') {
            if (customerNoticeRef.value){
              customerNoticeRef.value.show();
            }
          }else{
            gotoHome()
          }
        })

    }
    function gotoHome(){
      setTimeout(() => {
        router.push('index')
      }, 1000)
    }
    function onAgreeClick(){
      gotoHome()
    }
    const onDispatchKeyEvent = (keyEvent) => {
      console.log('----页面路由---SPLASH----onDispatchKeyEvent----------', keyEvent)
    }

    // const onBackPressed = () => {
    //   console.log('----页面路由---SPLASH----onBackPressed----------')
    // }

    return {
      onESCreate,
      // onBackPressed,
      onDispatchKeyEvent,
      customerNoticeRef,
      gotoHome,
      onAgreeClick
    }
  },
});
</script>

<style scoped>

.es-sdk-splash-css {
  width: 1920px;
  height: 1080px;
}

.es-sdk-splash-logo-css {
  width: 1920px;
  height: 1080px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: transparent;
}

.es-sdk-splash-title-css {
  font-size: 50px;
  margin-top: 5px;
}

</style>
